<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script src="./js/03-ajax.js"></script>
  <script>
    // 如果一个类中包含一个then方法，它会包装成一个promise
    // class User{
    //   then(resolve, reject) {
    //     resolve()
    //   }
    // }
    // async function get() {
    //   await new User();
    //   console.log('lisa')
    // }
    // get()

    class User{
      constructor(name) {
        this.name = name
      }
      then(resolve, reject) {
        let user = ajax(`http://localhost:3000/posts?${this.name}`)
        resolve(user)
      }
    }
    async function get() {
      let user = await new User('lisa');
      console.log(user)
    }
    get()
  </script>
</body>
</html>